package com.xzzz.irda.registry.service;


import org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration;
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties;
import org.springframework.cloud.client.serviceregistry.ServiceRegistry;

public class RedisAutoServiceRegistration extends AbstractAutoServiceRegistration<RedisRegistration> {

    private RedisRegistration registration;

    /**
     *
     * @param serviceRegistry 服务注册会传递给抽象类，由抽象类完成注册动作
     * @param properties
     * @param registration redisRegistration, 该类继承 RedisServiceInstance, 方便注册和服务发现时互相转换
     */
    protected RedisAutoServiceRegistration(ServiceRegistry<RedisRegistration> serviceRegistry,
                                           AutoServiceRegistrationProperties properties,
                                           RedisRegistration registration) {
        super(serviceRegistry, properties);
        this.registration = registration;
    }

    @Override
    protected Object getConfiguration() {
        return null;
    }

    /**
     * 是否自动注册
     * @return true:自动注册
     */
    @Override
    protected boolean isEnabled() {
        return true;
    }

    @Override
    protected RedisRegistration getRegistration() {
        return registration;
    }

    /**
     * 返回null即可
     * @return
     */
    @Override
    protected RedisRegistration getManagementRegistration() {
        return null;
    }
}
